# -*- coding:utf-8 -*-
import BasePage

class BaiduLoginPage(BasePage.BasePage):

    # 需要使用的变量
    test_url = 'https://www.baidu.com/'
    login_button_on_main_page = 'text>>>登录'
    username_input = "xpath>>>.//input[@name='userName']"
    password_input = "xpath>>>.//input[@name='password']"
    login_button = "id>>>TANGRAM__PSP_8__submit"
    error_text = "id>>>TANGRAM__PSP_8__error"
    register_button = "text>>>立即注册"

    # 打开登录页面
    def open_login_page(self):
        self.driver.click(self.login_button_on_main_page)

    # 输入用户名
    def input_username(self, username):
        self.driver.enter(self.username_input, username)

    # 输入密码
    def input_password(self, password):
        self.driver.enter(self.password_input, password)

    # 点击登录按钮
    def click_login(self):
        self.driver.click(self.login_button)

    # 获得错误提示信息
    def get_error_text(self):
        text = self.driver.get_text(self.error_text)
        return text

    # 点击去注册按钮
    def click_register_button(self):
        self.driver.click(self.register_button)


